<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/layouts/include/taglib.jsp" %> 

<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<meta name="decorator" content="default" />
<style type="text/css">

.backlist{float:right} 

</style>
</head>
<body>

<script >
//修改页面传过来的id
var uuid = "${param.id}";
$(document).ready(function() {
	//用于判断是新增项目还是修改项目
	$('#masterSaveForm').bootstrapValidator();
	$("#addDiv").collapse('show');
	if(uuid != null && uuid != ""){
		$('#typeTitle').text("修改知识库");
		Otod.ajax({
			url:"${ctx}/kb/main/getMasterById.do?uuid="+uuid,
			contentType: "application/x-www-form-urlencoded;",
			successFn:function(data){
				$('#uuid').val(data.uuid);
				$('#kbName').val(data.kbName);
				//下拉框赋值 把id值  更改为 #selectChange
				$('#selectChange').val(data.kbType);
				$('#selectChangeOne').val(data.kbSrc);
				$('#authorDate').val(data.authorDate);
				$('#depict').val(data.depict);
				//Otod.Msg.info("查询成功成功！");
			}
		});
		//查询数据库内容
		$("#typeTitleOne").text("修改知识库内容");
		
		selectMaster();
	}
	
	<%--
	$('input[type=file]').ace_file_input({
		style:'well',
		btn_choose:'点击选择上传文件',
		btn_change:null,
		no_icon:'icon-cloud-upload',
		droppable:true,
		thumbnail:'large'
	})
	--%>
})
//查询数据库内容
function selectMaster(){
	Otod.ajax({
		url:"${ctx}/kb/main/getContentById.do?uuid="+uuid,
		contentType: "application/x-www-form-urlencoded;",
		successFn:function(data){
			if(data==null){
				$("#typeTitleOne").text("新增知识库内容");
				return;
			}
			$('#uuidOne').val(data.uuid);
			$('#content').val(data.content);
			$('#atPath').val(data.atPath);
			$('#pageNum').val(data.pageNum);
			//Otod.Msg.info("查询成功成功！");
		}
	});
}
function addPrj(obj){
	$("#addDiv").collapse('show');
	
}

//取消
function abort(){
	$('#masterSaveForm').data('bootstrapValidator').resetForm();
}
//保存
function save(){
	if(!$('#masterSaveForm').data('bootstrapValidator').validate().isValid()){
		return;
	}
	//得到类型
	var kbType = $("#selectChange").val();
	//得到来源
	var kbSrc = $("#selectChangeOne").val();
	Otod.ajax({
		url:"${ctx}/kb/main/saveMaster.do?kbType="+kbType+"&kbSrc="+kbSrc,
		data: $('#masterSaveForm').serialize(),
		contentType: "application/x-www-form-urlencoded;",
		successFn:function(){
			$('#masterSaveForm button[type=reset]').click();		//重置form
			
			Otod.Msg.info("保存成功！");
		}
	});
}

jQuery(function($){
	var url = ctx + "/servlet/upload";
	
	Dropzone.options.myAwesomeDropzone = {
			  init: function() {
			    this.on("addedfile", function(file) { alert("Added file."); });
			  }
	};
	
	try {
		$(".dropzone").dropzone({
			url: url,
		    paramName: "file", // The name that will be used to transfer the file
		    maxFilesize: 1600, // MB
		    createImageThumbnails:false,
			addRemoveLinks : true,
			/* dictDefaultMessage :
			'<span class="bigger-150 bolder"><i class="icon-caret-right red"></i> Drop files</span> to upload \
			<span class="smaller-80 grey">(or click)</span> <br /> \
			<i class="upload-icon icon-cloud-upload blue icon-3x"></i>',
			dictResponseError: '文件上传出错了!' */
			
			//change the previewTemplate to use Bootstrap progress bars
			//previewTemplate: "<div class=\"dz-preview dz-file-preview\">\n  <div class=\"dz-details\">\n    <div class=\"dz-filename\"><span data-dz-name></span></div>\n    <div class=\"dz-size\" data-dz-size></div>\n    <img data-dz-thumbnail />\n  </div>\n  <div class=\"progress progress-small progress-striped active\"><div class=\"progress-bar progress-bar-success\" data-dz-uploadprogress></div></div>\n  <div class=\"dz-success-mark\"><span></span></div>\n  <div class=\"dz-error-mark\"><span></span></div>\n  <div class=\"dz-error-message\"><span data-dz-errormessage></span></div>\n</div>"
			dictRemoveFile: "删除"
		});
	} catch(e) {
		alert('上传组件不支持IE10以下版本!');
	}
});
</script>

<div id="addDiv" class="row clearfix collapse">
			<h2 class="header smaller lighter blue">
				<small><span id="typeTitle">新增知识库</span></small>
				<a href="${ctx}/jsp/pm/prj/projectList.jsp" class="backlist"><small>返回列表</small></a>
			</h2>
			<div class="col-xs-12">
				<form class="form-horizontal" role="form" name="masterSaveForm" id="masterSaveForm" 
					data-bv-feedbackicons-valid="glyphicon glyphicon-ok"
				    data-bv-feedbackicons-invalid="glyphicon glyphicon-remove"
				    data-bv-feedbackicons-validating="glyphicon glyphicon-refresh"
				>		
					<div class="row ">
						<div>
							<input type="text" id="uuid" name="uuid" value="" style="display: none">
						
						</div>
						<div class="col-sm-4 f-mb15" >
							<label for="kbName" class="col-sm-5 control-label">知识库名称</label>
							<div class="col-sm-7">
								<input type="text" class="form-control input-sm" id="kbName" name="kbName" value="" placeholder="知识库名称" data-bv-notempty data-bv-notempty-message="知识库名称必填">
							</div>
						</div>
						<div class="col-sm-4 f-mb15" >
							<label for="kbType" class="col-sm-5 control-label">知识库类型</label>
							<div class="col-sm-7">
								<select id="selectChange">
								<option value="知识库类型一">知识库类型一</option>
								<option value="知识库类型二">知识库类型二</option>
								<option value="知识库类型三">知识库类型三</option>
								<option value="知识库类型四">知识库类型四</option>
							</select>
							</div>
						</div>
						<div class="col-sm-4 f-mb15" >
							<label for="kbSrc" class="col-sm-5 control-label">知识库来源</label>
							<div class="col-sm-7">
								<select id="selectChangeOne">
								<option value="来源一">来源一</option>
								<option value="来源二">来源二</option>
							</select>
							</div>
						</div>
						
						<div class="col-sm-4 f-mb15" >
							<label for="authorDate" class="col-sm-5 control-label">知识库日期</label>
							<div class="col-sm-7">
								<input type="date" class="form-control input-sm" id="authorDate" name="authorDate" placeholder="知识库日期" data-bv-notempty data-bv-notempty-message="知识库日期必填">
							</div>
						</div>
						<div class="col-sm-4 f-mb15" >
							<label for="depict" class="col-sm-5 control-label">知识库描述</label>
							<div class="col-sm-7">
								<textarea rows="3" cols="20" class="form-control input-sm" id="depict" name="depict" placeholder="知识库描述" data-bv-notempty data-bv-notempty-message="知识库描述必填"></textarea>
							</div>
						</div>
					</div>
					
					<div class = "row">
						<h2 class="header smaller lighter blue">
							<small><span id="typeTitleOne">新增知识库内容</span></small>
						</h2>
					</div>
					
					
					<div class="row ">
						<div>
							<input type="text" id="uuidOne" name="uuidOne" value="" style="display: none">
						
						</div>
					
						<div class="col-sm-4 f-mb15" >
							<label for="atPath" class="col-sm-5 control-label">选择附件</label>
							<div id="dropzone" class="dropzone col-sm-7">
								<div class="fallback">
										<input name="file" type="file" multiple="" />
								</div>
							</div>
						</div>
						
						<div class="col-sm-4 f-mb15" >
							<label for="content" class="col-sm-5 control-label">知识库内容描述</label>
							<div class="col-sm-7">
								<textarea rows="3" cols="20" class="form-control input-sm" id="content" name="content" placeholder="知识库内容描述" data-bv-notempty data-bv-notempty-message="知识库内容描述必填"></textarea>
							</div>
						</div>
						<div class="col-sm-4 f-mb15" >
							<label for="pageNum" class="col-sm-5 control-label">知识库内容页码</label>
							<div class="col-sm-7">
								<input type="number" class="form-control input-sm" id="pageNum" name="pageNum" placeholder="知识库内容页码" data-bv-notempty data-bv-notempty-message="知识库内容页码必填">
							</div>
						</div>
					</div>
					<div class="row">
                        <div class="col-sm-12 button-submit" >
                            <button class="btn btn-xs btn-success" type="button" onclick="save()"><i class="icon-save"></i>保存</button>
                            <button class="btn btn-xs btn-default" type="reset" onclick="abort();"><i class="icon-remove"></i>重置</button>
                        </div>
                    </div>
                    <!-- 
                    <div class="row">
                    	<div class="dz-preview dz-file-preview">
							<div class="dz-details">
								<div class="dz-filename">
									<span data-dz-name></span>
								</div>
								<div class="dz-size" data-dz-size></div>
								<img data-dz-thumbnail />
							</div>
							<div class="progress progress-small progress-striped active">
								<div class="progress-bar progress-bar-success" data-dz-uploadprogress></div>
							</div>
							<div class="dz-success-mark"><span></span></div>
							<div class="dz-error-mark"><span></span></div>
							<div class="dz-error-message"><span data-dz-errormessage></span></div>
						</div>
                    </div>
                     -->
				</form>
		</div>
</div>
</body>
